/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "字符插座.h"



C_路径插座::C_路径插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_路径) {
	m_Value = f_alloc_PathProp(nullptr, L"路径");
	m_Value.m_私有 = true;
}

C_路径插座::~C_路径插座() {
	f_prop_Release(m_Value);
}

void* C_路径插座::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_路径) {
			return socket->f_getData(0);
		}
		else if (socket->m_Type == E_值类型::e_Type_Str) {
			
		}
	}

	return m_Value.m_Value;
}

void C_路径插座::f_setData(void* data, uint8 线程ID) {

}

std::string C_路径插座::f_构建变量代码() {
	return std::string();
}

bool C_路径插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case e_Type_路径:
	case e_Type_Str:
		return true;
	}
	return false;
}

void C_路径插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_prop_Load(m_Value, f);
}

void C_路径插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_prop_Save(m_Value, f);
}




C_字符串插座::C_字符串插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_Str) {
	m_Value = f_alloc_StrProp(nullptr, L"文本");
}

C_字符串插座::~C_字符串插座() {
}

void* C_字符串插座::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_Str) {
			return socket->f_getData(0);
		}
		else if (socket->m_Type == E_值类型::e_Type_路径) {

		}
	}

	return m_Value.m_Value;
}

void C_字符串插座::f_setData(void* data, uint8 线程ID) {

}

std::string C_字符串插座::f_构建变量代码() {
	return std::string();
}

bool C_字符串插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case e_Type_路径:
	case e_Type_Str:
		return true;
	}
	return false;
}

void C_字符串插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_prop_Load(m_Value, f);
}

void C_字符串插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_prop_Save(m_Value, f);
}
